package com.tepth.vehiclemaintenance.mvp.work.detail;

import com.tepth.vehiclemaintenance.bean.DetailDriverRemark;
import com.tepth.vehiclemaintenance.bean.MaintainListWork;
import com.tepth.vehiclemaintenance.net.ApiModel;
import com.tepth.vehiclemaintenance.net.observer.SimpleDisposableObserver;

import java.util.ArrayList;

/**
 * Created by TMVPHelper on 2017/05/15
 */
public class DetailPresenter extends DetailContract.Presenter {

    @Override
    void getMaintainDetail() {
        mRxManager.add(mModel.getMaintainDetail(mView.getAuthKey(), mView.getMaintainId())
                .subscribeWith(new SimpleDisposableObserver<ApiModel<DetailDriverRemark>>(mView) {
                    @Override
                    public void onSucceed(Object o) {
                        DetailDriverRemark driverRemark = (DetailDriverRemark) o;
                        mView.showMaintainDetail(driverRemark);
                    }
                }));
    }

    @Override
    void getOperatorList() {
        mRxManager.add(mModel.getOperatorList(mView.getAuthKey())
                .subscribeWith(new SimpleDisposableObserver<ApiModel<ArrayList<MaintainListWork.ListContentsBean.ListRemarkBean.OperationBean>>>(mView) {
                    @Override
                    public void onSucceed(Object o) {
                        ArrayList<MaintainListWork.ListContentsBean.ListRemarkBean.OperationBean> list =
                                (ArrayList<MaintainListWork.ListContentsBean.ListRemarkBean.OperationBean>) o;
                        mView.showOperatorList(list);
                    }
                }));
    }
}